package com.sc.controller.rui;


import com.sc.domain.Floor;
import com.sc.dto.FloorPageDto;
import com.sc.result.Result;
import com.sc.service.FloorService;
import com.sc.vo.FloorPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Author: Rui
 * @Date: 2024/11/23 15:56
 */
@RestController
@RequestMapping("floor")
@CrossOrigin
public class FloorController {
    @Autowired
    private FloorService floorService;
//   增删改查
    @PostMapping("add")
    public Result add(@RequestBody Floor floor){

        return Result.success("添加成功",floorService.addFloor(floor));
    }
    @DeleteMapping("delete/{id}")
    public Result<Boolean> delete(@PathVariable Integer id){

        return Result.success(floorService.deleteFloor(id));
    }
    @GetMapping("/get/{id}")
    public Result<Floor> getById(@PathVariable Integer id) {
        return Result.success(floorService.getById(id));
    }
    @PostMapping("update")
    public Result update(@RequestBody Floor floor){
        return Result.success("修改成功", floorService.updateFloor(floor));
    }
    @GetMapping("PageQuery")
    public Result PageQuery( FloorPageDto floorPageDto){
        return Result.success(floorService.PageQuery(floorPageDto));
    }

    @PostMapping("fuzzyQuery")
    public Result fuzzyQuery(@RequestBody FloorPageDto floorPageDto){
        return Result.success(floorService.fuzzyQuery(floorPageDto));
    }

    @DeleteMapping("deleteByList")
    public Result deleteByList(@RequestBody List<Integer> ids){
        return Result.success("删除成功", floorService.deleteByList(ids));
    }

    @GetMapping("get")
    public Result<List<FloorPageVo>> get() {
        return Result.success(floorService.get());
    }
}
